//
//  TT_Alert.m
//  ZKGX
//
//  Created by 王洋 on 2020/3/20.
//  Copyright © 2020 王洋. All rights reserved.
//

#import "TT_Alert.h"
#import "SCLAlertView.h"

@implementation TT_Alert

+ (void)alert:(NSString *)message {
    
    SCLAlertView *alert = [[SCLAlertView alloc] initWithNewWindowWidth:TTScreenWidth - 60];
    alert.showAnimationType = SCLAlertViewShowAnimationSlideInToCenter;
    [alert showTitle:@"温馨提示" subTitle:message style:SCLAlertViewStyleInfo closeButtonTitle:@"确定" duration:0.0];
}

+ (void)alert:(NSString *)message doneAction:(void (^)(void))doneAction {
    
    SCLAlertView *alert = [[SCLAlertView alloc] initWithNewWindowWidth:TTScreenWidth - 60];
    alert.showAnimationType = SCLAlertViewShowAnimationSlideInToCenter;
    
    SCLButton *doneButton = [alert addButton:@"确定" actionBlock:^{
        doneAction();
    }];

    doneButton.buttonFormatBlock = ^NSDictionary *{
        NSMutableDictionary *buttonConfig = [[NSMutableDictionary alloc] init];
        buttonConfig[@"backgroundColor"] = [UIColor blueColor];
        buttonConfig[@"textColor"] = [UIColor whiteColor];

        return buttonConfig;
    };
    
    [alert showTitle:@"温馨提示" subTitle:message style:SCLAlertViewStyleInfo closeButtonTitle:nil duration:0.0];
}

+ (void)alert:(NSString *)message cancleBtnTitle:(NSString *)cancleTitle cancleAction:(void (^)(void))cancleAction doneBtnTitle:(NSString *)doneTitle doneAction:(void (^)(void))doneAction {
    
    SCLAlertView *alert = [[SCLAlertView alloc] initWithNewWindowWidth:TTScreenWidth - 60];
    alert.showAnimationType = SCLAlertViewShowAnimationSlideInToCenter;
    
    [alert setHorizontalButtons:YES];
    
    SCLButton *cancleButton = [alert addButton:cancleTitle actionBlock:^{
        cancleAction();
    }];
    
    cancleButton.buttonFormatBlock = ^NSDictionary *{
        NSMutableDictionary *buttonConfig = [[NSMutableDictionary alloc] init];
        buttonConfig[@"backgroundColor"] = [UIColor whiteColor];
        buttonConfig[@"textColor"] = [UIColor blackColor];
        buttonConfig[@"borderWidth"] = @1.0f;
        buttonConfig[@"borderColor"] = [UIColor lightGrayColor];
        return buttonConfig;
    };
    
    SCLButton *doneButton = [alert addButton:doneTitle actionBlock:^{
        doneAction();
    }];

    doneButton.buttonFormatBlock = ^NSDictionary *{
        NSMutableDictionary *buttonConfig = [[NSMutableDictionary alloc] init];
        buttonConfig[@"backgroundColor"] = [UIColor redColor];
        buttonConfig[@"textColor"] = [UIColor whiteColor];
        return buttonConfig;
    };
    
    [alert showTitle:@"温馨提示" subTitle:message style:SCLAlertViewStyleNotice closeButtonTitle:nil duration:0.0];
}

@end
